<?php
// 文件版本信息数组
$fileVer = [
    'hplayer' => ['v1.0', 'hplayer.exe'],
    'test' => ['v2.0', '文本.txt'],
];

$app = $_GET['app'] ?? '';
getFile($fileVer[$app][0],$fileVer[$app][1]);

function getFile($file_ver,$file_name): void
{
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
    $fullUrl = $protocol . $_SERVER['HTTP_HOST'] . '/' . $file_name;
    header('Content-Type: application/json');
    echo json_encode([
        'code' => '200',
        'message' => '成功',
        'data' => [
            'version' => $file_ver,
            'file' => $fullUrl
        ]
    ]);
}